qual_race <- read.csv("dietrich_hayes_ps_data.csv")

library(survey)
library(ggplot2)

blacks <- svydesign(ids = ~1, data=subset(qual_race, qual_race$race=="Black"))

approval_blacks <- svyby(~symbolic_approval_scaled, ~ treat_race + ~treat_symbolism + ~treat_issue, blacks, svymean, na.rm=TRUE, vartype=c("se","ci"))
tiff("approval_blacks_alternate.tiff", units="in", width=8, height=8, res=1200)
ggplot(approval_blacks, aes(x=treat_issue, y=symbolic_approval_scaled)) +
  geom_pointrange(aes(ymin=ci_l, ymax=ci_u), size=0.6) +
  facet_grid(treat_symbolism ~ treat_race) +
  #scale_x_discrete(name="", labels=c("Non-Symbolic","Symbolic")) +
  scale_y_continuous(name="Average Approval Rating", breaks=seq(0,1,.2), limits=c(0,1)) + 
  theme_bw() + displayprefs +
  ggtitle("Approval rating (Black Respondents)" )
dev.off()
